import type { IRentChangeOrderAddress, IRentMachineOrderInfoList } from "@/types/rentMachineManage/rentMachineOrderInfo";

/* 修改地址 */
function useUpdateAddress(fn?: () => void) {
  const updateAddressVisible = ref(false);
  const updateAddressForm = ref<IRentChangeOrderAddress>({
    id: 0,
    name: "",
    mobile: "",
    province: "",
    city: "",
    district: "",
    address: ""
  });

  /* 打开修改地址模态框 */
  function handleEditAddress(row: IRentMachineOrderInfoList) {
    updateAddressForm.value.id = row.id;
    updateAddressVisible.value = true;
  }

  /* 修改地址成功回调 */
  function handleEditAddressSuccess() {
    updateAddressVisible.value = false;
    if (fn) {
      fn();
    }
  }

  return {
    updateAddressVisible,
    updateAddressForm,
    handleEditAddress,
    handleEditAddressSuccess
  };
}

export default useUpdateAddress;
